#pragma once

extern u32 g_hwnd;

enum
{
    K_NONE = 0, 
    K_ESC  = 0x1B,
	K_MOUSE_L = 0xF1,
	K_MOUSE_R = 0xF2,
	K_MOUSE_M = 0xF3,
	K_MOUSE_WU = 0xF4,
	K_MOUSE_WD = 0xF5
};

class CInput
{
public:
	CInput()
	{
		Reset();
		Update();
	}
	~CInput()
	{
	}
	void Reset()
	{
		memset(m_downs,0,sizeof(bool)*256);
	}
	void SetState(u32 _key,bool _state)
	{
		if(m_downs[_key] && (!_state))
		{
			m_hits[_key] = true;
			m_last = _key;
		}
		m_downs[_key] = _state;
	}
	void Update()
	{
		memset(m_hits,0,sizeof(bool)*256);
		m_last = K_NONE;
		SetState(K_MOUSE_WU,false);
		SetState(K_MOUSE_WD,false);

		m_mdx = m_pos.x - m_mx;
		m_mdy = m_pos.y - m_my;
		m_mx   = m_pos.x;
		m_my   = m_pos.y;
	}
	void SetRC(RECT& _rc){m_rc=_rc;}
	void SetPos(POINT& _pt){m_pos=_pt;}
	
public:
	bool	  m_downs[256];
	bool	  m_hits[256];

	u32		  m_last;

	u32		  m_mx;
	u32		  m_my;
	u32		  m_mdx;
	u32		  m_mdy;

	RECT	  m_rc;
	POINT	  m_pos;
};